<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>原材料订单详细</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../res/layui-v2.5.6/css/layui.css" media="all">
    <script type="text/javascript" src="../../../res/js/jquery-3.1.1.min.js"></script>
</head>
<body>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
    <div class="demoTable">
        搜索：
        <div class="layui-inline">
            <input class="layui-input" name="materialName" id="materialName" autocomplete="off" placeholder="请输入原材料名称">
        </div>
        <button class="layui-btn" data-type="reload" id="sousuo" onclick="seach(this)">搜索</button>
    </div>
</script>

<script type="text/javascript" src="../../../res/layui-v2.5.6/layui.js"></script>
<script type="text/javascript" src="../../../res/js/util.js"></script>

<script>
    var openIndex = null;
    var table = null;
    var laydate = null;
    layui.use(['table', 'laydate'], function () {
        table = layui.table;
        laydate = layui.laydate;

        table.render({
            method:"POST",
            elem: '#test'
            , url: getRootPath()+'/hqPurchasedetails/showAll'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,totalRow: true  //开启合计
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , cols: [[
                // {type: 'checkbox', fixed: 'left'},
                // , {field: 'purchaseId', title: '采购订单Id', width: 140,fixed: 'left',align:"center"}
                // , {field: 'detailsId', title: '采购明细id', width: 140,align:"center"}
                 {field: 'remark', title: '采购备注', width: 170,align:"center", totalRowText: '合计'}
                , {field: 'materialName', title: '原材料名称', width: 140,align:"center"}
                , {field: 'count', title: '采购重量(g)', width: 180,align:"center", totalRow: true,templet:function (d) {
                    return Math.round(d.count);
                    }}
                , {field: 'materialMoney', title: '采购价', width: 120,align:"center", totalRow: true}
                , {field: 'money', title: '总价格', width: 120,align:"center", totalRow: true}
            ]]
            , page: true
            , id: 'test'
            ,where: {
                purchaseId:getQueryString("purchaseId")
            }
        });
    });

    //搜索
    function seach() {
        table.reload('test', {
            where: {
                materialName: $("#materialName").val(),
            },
            page: {
                curr: 1//从第一页开始查询
            }
        });
    }
</script>
</body>
</html>